package com.rockcent.service;

import com.rockcent.common.common.PageResult;
import com.rockcent.mall.lib.domain.MallCashCoupon;
import com.rockcent.mall.lib.domain.MallOrder;
import com.rockcent.mall.lib.dto.*;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;

/**
 * Created by zhangjh on 2016/12/19.
 */
public interface MallCashCouponSrv {
    String RESOURCE_PATH_INTEGRATION_CHANNEL = "templates/integration_channel.xls";
    String FILE_NAME_INTEGRATION = "积分渠道统计.xls";

    /**
     * @param vo
     */
    MallCashCoupon save(MallCashCouponDto vo, Long mallId);

    /**
     *
     * @param id
     * @return
     */
    MallCashCoupon findOne(Long id);

    /**
     *
     * @param mallCashCoupon
     * @param mallId
     */
    void save(MallCashCoupon mallCashCoupon, Long mallId);

    /**
     *
     * @param mallCashCoupon
     * @param mallId
     */
    void stop(MallCashCoupon mallCashCoupon, Long mallId);

    /**
     *
     * @param mallId
     * @param dto
     * @param pageResult
     * @return
     */
    PageResult<MallCashCouponDto> findIntegrationCashCouponPage(Long mallId, MallCashCouponDto dto, PageResult pageResult);

    /**
     *
     * @param vo
     * @param mallId
     * @return
     */
    MallCashCoupon update(MallCashCoupon vo, Long mallId);

    /**
     *
     * @param vo
     */
    void delete(MallCashCoupon vo);

    /**
     * 优惠券同步
     *
     * @param reqDto
     * @param channelId
     * @return
     */
    List<IntegrationCouponRespDto> queryList(IntegrationCouponReqDto reqDto, String channelId);

    /**
     * 积分兑换
     * @param exchangeCode
     * @param channelId
     * @param dto
     */
    void exchange(String exchangeCode, String channelId, IntegrationCouponReqDto dto);

    /**
     *
     * @param response
     * @param dtos
     * @param mallId
     * @throws IOException
     * @throws InvalidFormatException
     */
    void exchange(HttpServletResponse response, List<IntegrationChannelDto> dtos, Long mallId) throws IOException, InvalidFormatException;

    /**
     *
     * @param integrationChannelId
     * @return
     */
    Long queryTotalNumByChannelId(Long integrationChannelId);

    /**
     * 还原积分卡券和现金券
     * @param mallOrder
     */
    BigDecimal refundIntegrationCoupon(MallOrder mallOrder);


    /**
     *
     * @param mallOrder
     * @param isNeedRefundMallFund
     */
    BigDecimal refundIntegrationCoupon(MallOrder mallOrder,boolean isNeedRefundMallFund);

    /**
     * 查询卡券的状态
     * @param reqDto
     * @param channelId
     * @return
     */
    IntegrationCouponDetailRespDto queryInfoByExchangeCodeAndType(String exchangeCode, IntegrationCouponReqDto reqDto, String channelId);

    /**
     *
     * @param faceVal
     * @param channelId
     * @param dto
     * @return
     */
    IntegrationCouponRespDto exchange(BigDecimal faceVal, String channelId, IntegrationCouponReqDto dto);
}
